<template>
  <div>
    <el-breadcrumb separator-icon="ArrowRight" style="margin: 16px">
      <el-breadcrumb-item :to="{ path: '/adminHome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户信息管理</el-breadcrumb-item>
      <el-breadcrumb-item>租客信息</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card style="margin: 15px; min-height: calc(100vh - 111px)">
      <div style="color: black; font-size: 20px;font-weight: bolder; text-align: center;">租客信息</div>
      <div>
        <div style="margin: 40px 0">
          <div style="margin: 10px 0">
            <el-input v-model="search" 
                      @input="filterData"
                      clearable 
                      placeholder="请输入租客ID号" 
                      prefix-icon="Search"
                      style="width: 20%"/>
            <el-button icon="Search" style="margin-left: 5px" type="primary" @click="filterData"></el-button>
            <el-button icon="refresh-left" style="margin-left: 10px" type="default" @click="reset"></el-button>
            <div style="float: right">
              <el-tooltip content="添加" placement="top">
                <el-button icon="plus" style="width: 50px" type="primary" @click="add"></el-button>
              </el-tooltip>
            </div>
          </div>
        </div>
        <!--表格-->
        <el-table v-loading="loading" :data="tableData" border max-height="705" style="width: 100%">
          <el-table-column label="租客ID" prop="tenantId"/>
          <el-table-column label="用户名" prop="username" sortable/>
          <el-table-column label="密码" prop="password" />
          <el-table-column label="电话号码" prop="phone"/>
          <el-table-column :show-overflow-tooltip="true" label="邮箱" prop="email"/>
          <el-table-column label="操作" width="130px">
            <template #default="scope">
            <el-space direction="vertical" alignment="center" style="margin-left: 13%; margin-top: 5%">
              
                <el-button icon="Edit" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
                <el-popconfirm title="确认删除？" @confirm="handleDelete(scope.row.tenantId)">
                  <template #reference>
                    <el-button icon="Delete" type="danger">删除</el-button>
                  </template>
                </el-popconfirm>
              
            </el-space>
            </template>
          </el-table-column>
        </el-table>
        <!--分页-->
        <div style="margin: 40px 0">
          <el-pagination
              v-model:currentPage="currentPage"
              :page-size="pageSize"
              :page-sizes="[5, 10, 15]"
              :total="total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"></el-pagination>
        </div>
        <div>
          <!--弹窗-->
          <el-dialog v-model="dialogVisible" title="添加租客信息" width="30%" @close="cancel">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
              <!-- <el-form-item label="租客ID" prop="tenantId" v-if="!judgeAddOrEdit">
                <el-input v-model="form.tenantId" :disabled="judgeAddOrEdit" style="width: 80%"></el-input>
              </el-form-item> -->
              <el-form-item label="用户名" prop="username">
                <el-input v-model="form.username" :disabled="false" style="width: 80%"></el-input>
              </el-form-item>
              <el-form-item label="密码" prop="password">
                <el-input v-model="form.password" :disabled="false" :show-password="showpassword" style="width: 80%"></el-input>
              </el-form-item>
              <el-form-item label="电话号码" prop="phone">
                <el-input v-model.number="form.phone" style="width: 80%"></el-input>
              </el-form-item>
              <el-form-item label="邮箱地址" prop="email">
                <el-input v-model="form.email" style="width: 80%"></el-input>
              </el-form-item>
            </el-form>
            <template #footer>
              <span class="dialog-footer">
                <el-button @click="cancel">取 消</el-button>
                <el-button type="primary" @click="save">确 定</el-button>
              </span>
            </template>
          </el-dialog>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script src="@/assets/js/TenantInfo.js"></script>